/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.uniscol.model;

import fr.uniscol.siecle.model.CorrespondanceSiecleSts;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Christophe
 */
public class RapportTraitementImportSTS extends RapportTraitement {
    
    private long nextId = 1;
    
    private List<CorrespondanceSiecleSts> correspondances = null;

    public List<CorrespondanceSiecleSts> getCorrespondances() {
        if(correspondances == null){
            correspondances = new ArrayList<CorrespondanceSiecleSts>();
        }
        return correspondances;
    }

    public void setCorrespondances(List<CorrespondanceSiecleSts> correspondances) {
        this.correspondances = correspondances;
    }
    
    public void addCorrespondanceClasse(String idSiecle, String idSts){
         addCorrespondance(idSiecle, idSts, CorrespondanceSiecleSts.CORRESPONDANCE_DIVISION);
    }
    
    public void addCorrespondanceGroupe(String idSiecle, String idSts){
         addCorrespondance(idSiecle, idSts, CorrespondanceSiecleSts.CORRESPONDANCE_GROUPE);
    }
    
    public void addCorrespondanceMatiere(String idSiecle, String idSts){
        addCorrespondance(idSiecle, idSts, CorrespondanceSiecleSts.CORRESPONDANCE_MATIERE);
    }
    
    public void addCorrespondance(String idSiecle, String idSts, String type){
        CorrespondanceSiecleSts cor = new CorrespondanceSiecleSts(idSiecle, idSts, type);
        
        if(!getCorrespondances().contains(cor)){
            getCorrespondances().add(cor);
            cor.setId(nextId++);
        }else{
            cor = getCorrespondances().get(getCorrespondances().indexOf(cor));
            if(cor != null){
                cor.setNbOccurences(cor.getNbOccurences() + 1);
            }
        }
    }
}
